package com.androidx.p013lv.invention.activity;

import android.view.View;
import androidx.recyclerview.widget.GridLayoutManager;
import com.androidx.p013lv.base.bean.TwoBean;
import com.androidx.p013lv.base.bean.VideoBean;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.listener.ItemClickListener;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.utils.NetUtil;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.androidx.p013lv.invention.C1069R;
import com.androidx.p013lv.invention.adapter.AdapterFourteenMore;
import com.androidx.p013lv.invention.databinding.ActivitySvipRecommendBinding;
import com.gyf.immersionbar.ImmersionBar;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;

/* renamed from: com.androidx.lv.invention.activity.SvipGoldActivity */
public class SvipGoldActivity extends BaseActivity<ActivitySvipRecommendBinding> implements OnRefreshLoadMoreListener {
    String HTTP_TAG = "queryVideoMore";
    AdapterFourteenMore adapter;
    int lastId = 0;
    public String name;
    public int stationId;

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return C1069R.C1074layout.activity_svip_recommend;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        ((ActivitySvipRecommendBinding) this.binding).tvTitle.setText(this.name);
        ((ActivitySvipRecommendBinding) this.binding).refresh.setOnRefreshListener(this);
        ((ActivitySvipRecommendBinding) this.binding).refresh.setOnLoadMoreListener(this);
        ((ActivitySvipRecommendBinding) this.binding).tvBack.setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.invention.activity.SvipGoldActivity.View$OnClickListenerC11031 */

            public void onClick(View view) {
                SvipGoldActivity.this.finish();
            }
        });
        ((ActivitySvipRecommendBinding) this.binding).recycler.setLayoutManager(new GridLayoutManager(getActivity(), 3));
        this.adapter = new AdapterFourteenMore();
        ((ActivitySvipRecommendBinding) this.binding).recycler.setAdapter(this.adapter);
        this.adapter.setItemListener(new ItemClickListener() {
            /* class com.androidx.p013lv.invention.activity.SvipGoldActivity.C11042 */

            @Override // com.androidx.p013lv.base.listener.ItemClickListener
            public void onItemClick(View view, int i) {
                SvipGoldActivity svipGoldActivity = SvipGoldActivity.this;
                svipGoldActivity.startVideoPlay(((VideoBean) svipGoldActivity.adapter.getDataInPosition(i)).getVideoId());
            }
        });
        ((ActivitySvipRecommendBinding) this.binding).statusLayout.setOnRetryListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.invention.activity.SvipGoldActivity.View$OnClickListenerC11053 */

            public void onClick(View view) {
                SvipGoldActivity.this.lastId = 0;
                SvipGoldActivity.this.getInfo();
            }
        });
        getInfo();
    }

    /* access modifiers changed from: package-private */
    public void getInfo() {
        if (this.lastId == 0) {
            AdapterFourteenMore adapterFourteenMore = this.adapter;
            if (!(adapterFourteenMore == null || adapterFourteenMore.getData() == null || this.adapter.getData().size() <= 0)) {
                this.adapter.clear();
            }
            if (!NetUtil.isNetworkAvailable()) {
                ((ActivitySvipRecommendBinding) this.binding).statusLayout.showNoNet();
                return;
            }
            ((ActivitySvipRecommendBinding) this.binding).statusLayout.showLoading();
        }
        HttpUtils.getInsatance().get(UrlManager.getInsatance().queryVideoMore(this.stationId, this.lastId, 30), new HttpCallback<BaseRes<TwoBean>>(this.HTTP_TAG) {
            /* class com.androidx.p013lv.invention.activity.SvipGoldActivity.C11064 */

            public void onLvSuccess(BaseRes<TwoBean> baseRes) {
                ((ActivitySvipRecommendBinding) SvipGoldActivity.this.binding).statusLayout.hideLoading();
                ((ActivitySvipRecommendBinding) SvipGoldActivity.this.binding).refresh.finishRefresh();
                ((ActivitySvipRecommendBinding) SvipGoldActivity.this.binding).refresh.finishLoadMore();
                if (baseRes.getCode() == 200) {
                    if (baseRes.getData() != null && baseRes.getData().getList() != null && baseRes.getData().getList().size() > 0) {
                        SvipGoldActivity.this.adapter.setDomain(baseRes.getData().getDomain());
                        if (SvipGoldActivity.this.lastId == 0) {
                            SvipGoldActivity.this.adapter.setData(baseRes.getData().getList());
                            ((ActivitySvipRecommendBinding) SvipGoldActivity.this.binding).refresh.resetNoMoreData();
                            return;
                        }
                        SvipGoldActivity.this.adapter.setDatasInEnd(baseRes.getData().getList());
                    } else if (SvipGoldActivity.this.lastId == 0) {
                        ((ActivitySvipRecommendBinding) SvipGoldActivity.this.binding).statusLayout.showEmpty();
                    } else {
                        ((ActivitySvipRecommendBinding) SvipGoldActivity.this.binding).refresh.finishLoadMoreWithNoMoreData();
                    }
                } else if (SvipGoldActivity.this.lastId == 0) {
                    ((ActivitySvipRecommendBinding) SvipGoldActivity.this.binding).statusLayout.showError();
                } else {
                    ToastUtils.getInstance().showWeak(baseRes.getMsg());
                }
            }
        });
    }

    @Override // com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
    public void onLoadMore(RefreshLayout refreshLayout) {
        AdapterFourteenMore adapterFourteenMore = this.adapter;
        if (adapterFourteenMore == null || adapterFourteenMore.getData() == null || this.adapter.getData().size() == 0) {
            ((ActivitySvipRecommendBinding) this.binding).refresh.finishLoadMore();
            return;
        }
        this.lastId = ((VideoBean) this.adapter.getLastDataInPosition()).getVideoId();
        getInfo();
    }

    @Override // com.scwang.smartrefresh.layout.listener.OnRefreshListener
    public void onRefresh(RefreshLayout refreshLayout) {
        this.lastId = 0;
        getInfo();
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        super.onDestroy();
        HttpUtils.getInsatance().cancelTag(this.HTTP_TAG);
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivitySvipRecommendBinding) this.binding).toolbar).init();
    }
}
